package day6;

/**
 * @author oldliu
 * @since 1.0
 */
public class Zhongweish {
    public static void main(String[] args) {
        int[] a = {21, 23, 22, 73, 49, 75, 74, 42, 88, 56, 88, 32, 23, 29, 20};
        double[] b = new double[a.length];
        int i, j = 0, sum = 0;
        double x;
        for (i = 0; i < a.length; i++) {
            sum += a[i];
        }
        x = (double) sum / a.length;
        System.out.println(x);
        double m = a[0] - x >= 0 ? a[0] - x : x - a[0];
        j = 0;
        for (i = 1; i < a.length; i++) {
            double t = a[i] - x >= 0 ? a[i] - x : x - a[i];
            if (m > t) {
                m = t;
                j = i;
            }
        }

        System.out.println("中位数是" + a[j]);
    }
}
